Previous Next Contents Generated Index Doc Set



CHAPTER 13 : Tips And Hints


Introduction

This chapter incorporates some points which you may find useful when using Visaj along with some issues which could be termed "troubleshooting". If you become "stuck" or confused, scan this chapter to see if any relevant information is provided. Check here also for advice on using Visaj. The tips and hints are divided into the following categories:


User Interface


How do I make a "main" method?

Tell Visaj which method should be the "main" method of your application by selecting the method in the Class Editor and then choosing "Main method" from the Method menu. A small star next to the method reminds you which has been designated "main". You do not have to mark any of the methods as "main", but remember to add one somewhere in your application!

Further information:


The hierarchy has disappeared after looking at the Event bindings or method signature pages.

The area of the Class Editor window which contains editors for the methods in the classes is organized as a tabbed panel. This is like a stack of cards with a tab on each card showing its name (or function in this case). Selecting a tab brings the associated "card" to the top. If you have been looking at the Event bindings or method signature "card", you will have to select the "Bean creation" tab to bring the hierarchy building "card" to the front again.

Further information:


I want to reparent some child objects

By using a combination of Cut/Clear/Paste you can reparent whole groups of objects. Here is an example:

  1. You have created a hierarchy of Frame-Splitter-{Button, Toggle, TextField}, as shown in Figure 13-1.

Figure  13-1 First Parenting

  2. Select the Button, Toggle and TextField.
  3. Press the Cut button on the toolbar (or select from the Edit menu).
  4. Select the Splitter in the hierarchy.
  This is a Diamond component.
  5. Press the Clear button on the toolbar (or select from the Edit menu).
  6. Make sure the Frame is selected and press the Paste button on the toolbar (or select from the Edit menu).
  7. You have now changed to a structure of Frame-Panel-{Button, Toggle, TextField}, keeping the same child objects, as shown in Figure 13-2.
 

Figure  13-2 Second Parenting

Further information:


How do I manage lots of classes for my application?

The Class Editor works with one class at a time. The chances are that your application will have more than one class in it. To keep track of them all and to make them easily available for editing, do one of the following:

  1. Use the Visaj project window. Using this you can keep a list of all the classes in your application and simply double-click over them to edit them in the Class Editor
  2. Use an Integrated Development Environment (IDE). IDEs are commercial packages for organizing, creating, compiling and debugging Java application. Some IDEs can be configured to work with Visaj's save files.
Further information:


How do I use CheckboxGroups?

The CheckboxGroup, whose palette icon is shown in Figure 13-3, is an invisible bean. As with all invisible beans, you must have nothing selected in the design area to add it to your design. It is then places at the top of the design area, alongside the roots of hierarchies.

Figure  13-3 CheckboxGroup Palette Icon

The CheckboxGroup provides a means of grouping Checkboxes and giving them radio button behavior (only one in the group can be "set"). To link one CheckboxGroup to a group of Checkboxes, do the following, assuming that you have already added some Checkboxes and a CheckboxGroup to your design:

  1. Select the Checkboxes and display the Property Sheet.
  2. Select the "checkboxgroup" property.
  3. In the property editor at the bottom of the Property Sheet, select the "Variable name" option.
  4. Type the variable name of your CheckboxGroup into the text field.

Although you will not see the radio behavior in the dynamic display, the generated code will display such behavior.

Further information:


I can't see the objects in my design properly, particularly when I add invisible beans

The Class Editor window is divided into several areas. You can alter the amount of window space used by the containment hierarchy and by the class structure editor by:

Figure  13-4 Demonstration of Splitter Panel Divider

Further information:


I can't find the other windows in my Visaj session

The Windows menu, available from all of Visaj's editors, lists all open windows in your current Visaj session. Selecting one of these menu items brings the window to the front.


Note - On some window systems, if the selected window is iconized the icon is brought to the front but the window is not opened.
Further information:


I have added a file selection dialog to my design but it does not appear in the dynamic display

By default, Visaj sets the "visible" resource for file selection dialogs to "false" because, being modal, they cause confusion when they appear as they have to be dismissed. you can make a file selection dialog appear either by explicitly setting the "visible" resource or by setting up an event binding which causes it to appear.

Further information:


How do I add components to the base component?

To define methods which add components to the class, add "this" to the method design when the class is a subclass of java.awt.Component or MenuComponent. "this", in such a case, refers to the class itself so any components added to it are added to the base component (the class itself).

Further information:


Visaj won't exit

If you try exiting visaj and nothing happens, it may be because you have some iconized class editors that have put up a dialog asking if you want to save changes, but the dialog cannot be seen because the editor is iconized.


Visaj is not responding/behaving strangely. Can I get any feedback on what is happening?

Select "Java Console..." from the Options menu. If any exceptions have been generated, they are displayed in this window.


Event Bindings


How can I set up an action to be performed when the Close button in a Frame (or Dialog) is pressed?

To set up an event binding on the close button of a Frame or Dialog, display the Event Binding editor and select the Frame or Dialog as the "Source". Next, select "windowClosing" from the list of "window" actions in the "Type" list.

To exit the application, select the class (default "MyClass") as the "Object" and a class method previously defined by you. In the generated code, you would then add the following line to your method:

System.exit(1);

To hide the window, select the frame (or the dialog) as the "Object" and then the "hide" method.


Dragging a line between two components doesn't display the Event Bindings Editor

Holding down the control key while dragging between two components causes the Event Bindings Editor to be displayed, primed with the two components. If, however, the control key is released at any time before the mouse button is released, the Editor is not displayed. Instead, the second component is simply selected in the design hierarchy,

Further information:


Adding an event binding causes Exceptions and does not work

If you are trying to set up an event binding using Beans from a compressed JAR file, you may find that the event binding is not created and Exceptions are printed in a terminal window. This is because the compiler which Visaj is using "behind the scenes" cannot access compressed listener or event objects.

Further information:


Loading X-Designer Save Files


When I try to load my design, one of the file dialogs in it appears, but then Visaj freezes up.

File selection dialogs are modal, therefore if you have set the "visible" resource for the file selection dialog to "true", Visaj will freeze when it displays the dialog in its dynamic display. This happens on import as well as with normal loading. If you cancel the file dialog when it appears, Visaj will continue loading. By default, the "visible" resource is set to "false".

Further information:


Visaj seems to have confused the title of an MWT FramedPanel with its contents - or - Visaj is not displaying the correct heading (`error', `information', etc.) on my dialog template.

You can specify which of a FramedPanel's children is its title child by using a property, and you can specify an IconMessagePanel's icon in a similar manner. However, properties of type Component can only be specified using a code expression property setting in Visaj.

These settings do not take effect in the dynamic display. The dynamic display, therefore, may use the wrong child as title or icon when displaying the FramedPanel or IconMessagePanel. Generated code, however, will use the correct child.

Further information:


My Motif XmRadioBox has disappeared on Visaj

Motif designs which use XmRadioBoxes, when brought over to Visaj, will use Checkboxes inside Panels. You will have to edit your design to add radio-box behavior.

Further information:


A message "Unknown class <name>_user" is displayed when loading the X-Designer generated file.

You may see such a message if your X-Designer design was captured (using XD/Capture) in Java mode. In some circumstances XD/Capture overrides some of the classes in the design. You should replace the class mentioned in the error message with <name>_c.


The design seems to have loaded, but nothing is displayed.

Check whether the visible property on the topmost frame has been set to false. This sometimes occurs in designs captured with XD/Capture.


Palette Configuration


How do I add components onto the Visaj palette?

Visaj loads the Java AWT components and the Diamond components by default onto the component palette. If you wish to add components from other vendors or your own homemade components, you can do one of the following:

Merging in a palette file also requires that you set your CLASSPATH environment variable so that Java can locate the new classes.

Further information:


When I do "Merge Palette", no components are added to my palette

If a message is displayed saying that Visaj cannot handle the classes in the palette file you are trying to merge in, check that you have set your CLASSPATH environment variable so that Java can locate the classes mentioned in the palette file. You can set up the CLASSPATH to point to a JAR file containing the classes or to a directory with the classes in it.

Further information:


No Beans have been added to my palette after loading a JAR file

The following are some possible reasons why Java Beans have not loaded from a JAR file:

  1. There is no manifest file in the JAR.
  2. There is a manifest file, but no mention of the Bean to be loaded.
  3. There is a manifest file which refers to the Bean, but the entry for that Bean is missing the line:
Java-Bean: true
Further information:


On Microsoft Windows, my specified palette file has been ignored or cannot be found

If you have specified a palette file either on the command line or using VISAJOPTS, make sure that there are no spaces in the path. This is especially noticeable on Microsoft Windows where you may be referring to files in the "Program files" directory. In such a case, try substituting the DOS-style "Program~1", as in the following example:

-Dvj.AWTPalette.file=D:\Program~1\Visaj\palettes\JFC11.palette


Layout


How do I specify no layout at all for a container?

In Visaj, containers are always given a default layout. You can choose to have no layout for a container by choosing "null" for the container's layout property in the Property Sheet. You may still use the Layout Editor, which will allow you to position the container's children absolutely (i.e. with no constraints or resize behavior). The children can also be resized in the Layout Editor in this case.

Further information:


When using the Null layout, the child objects have disappeared

When you have chosen to have no layout for a container (choosing "null" for the layout property), the Layout Editor allows you to move and resize the children but cannot show the insets of the container. The inset is a border around the edge. This means that the child components can "disappear" underneath the inset in the dynamic display window. Move the components in the Layout Editor so that they are visible in the dynamic display window, which updates immediately.


(Motif only) When using the Null layout, the generated application takes up the whole screen

If, having set no layout ("null") on the root window of your application, the generated and compiled application takes up the whole screen, specify an explicit size for the frame by setting the "size" property in the Property Sheet for the fame.


Note - This only applies to applications running under Motif.


How do I simply place the children of a container at a particular location?

If it is important that you position the children of a container at an absolute location so that they stay there regardless of whether the container is resized, use the Null layout. Display the Property Sheet for the container, select the layout property and choose "null" from the option menu at the bottom.

The major usefulness of the Null layout is when the child components must fit in with a background image (a button over a picture for example).

Further information:


Can I undo and redo actions in the Layout Editor?

You can. Use the appropriate buttons in the Class Editor window. The Class Editor will undo and redo the last actions regardless of whether they took place in the Layout Editor or directly in the Class Editor window.

Further information:


How do I edit the "insets" of a container?

To edit the insets in a GridBagConstraints object, use the Layout Editor. The area on the right of the Editor window allows you to edit the GridBagConstraints for the child component which is selected in the area on the left. Enter values in the "left", "Right", "Top" and "Bottom" fields to change these insets.

There is no direct way of editing the insets of an AWT container. To do this, you would have to create a subclass of the container and then override the getInsets() method.


Generated Code


The generated application does not run

Make sure that you have a "main" method. If you have not designated a method in one of your classes as the "main" and you have not linked in your own "main" method, none of your code will be called.

Further information:


I generated code using one class name and regenerated using another. Where is the first Java source file?

Visaj always generates Java using the name of the class for the name of the Java source file. This is a requirement of the Java language. If you have changed the name of the class in Visaj, Visaj treats this as an update and generates to a new file using the new class name. If, however, the "Update existing files" toggle in the Generate dialog is set, the previously generated source file is removed. This is to ensure that the design and the generated code are always in step. If you wish to retain the previously generated file. unset the "Update existing file" toggle before generating. If you have made any changes to the generated source file, unsetting the "Update existing files" toggle and regenerating will lose them.


When I try to run my generated application, it stops with a NullPointerException at a line where my generated code is trying to access an image file

In the generated code, image files are loaded as resources using the class loader. The string typed into the "Runtime resource path" text field is passed directly to the class loader method getResource. By default, Visaj generates code which assumes that the images you specify are in the same directory as the class file which is accessing them. If you have copied your class files to a directory matching your package, make sure that you have copied your image files too. Similarly, if you have any serialized object files (ending in ".ser"), you will also need to copy these.

Further information:


I have copied my generated Java files to another platform and recompiled but the compiled application won't run

Make sure that you have also copied any serialized object files (ending in ".ser"). These files are generated by Visaj for objects which you wish to be initialized by deserialization and for objects which have been customized. This applies not only when copying to another platform but also to another directory on the same platform, such as when placing the class files into their package location. When moving your Java or class files around, make sure that you have also taken any image files used by your application.

Further information:


With Diamonds in my design, I can't compile the generated code

If you are using any of the Diamond components in any part of your application, make sure that you have specified the Diamonds jar file in your CLASSPATH environment variable1 before compiling. If you have not done so, a message saying that the class cannot be found in the import will be displayed.

Further information:


How do I add my own code to the generated code?

There are essentially two ways of adding your own code to the generated code:

  1. Subclassing the generated class
  2. Editing the generated code

The first option, subclassing the generated class, is by far the cleanest way and the easiest to maintain. Your new class would look something like this:

public class NewClass extends GeneratedClass {
	public void generatedMethod() {
		super.generatedMethod();
		...
	}
}

Points to remember when doing this are:

If you decide to edit the generated code directly, make sure that you pay attention to the special comments put in by Visaj, otherwise your changes may be lost when code is regenerated.

Further information:



1 Environment variables are available on UNIX and Microsoft Windows. Other platforms, such as the Apple macintosh, use their own method of setting a CLASSPATH. Please refer to the relevant Java documentation for more information.


Previous Next Contents Generated Index Doc Set

Copyright © 1998, 1999 Pacific Imperial Inc., TakeFive Software Inc. All Rights Reserved.